<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script src="js/jquery-1.11.0.min.js"></script>
</head>
<body>
    <button id="crossSend">发送跨域访问</button>
</body>

<script>
    $("#crossSend").click(function (){
        //当前是81服务器，发送请求到80服务器,路径要写全
        let url = "http://localhost:80/resp/test6";
        let params = {
            uname:"zs",
            age:20,
            pwd:"123",
            bir:"2000-11-11"
        }

        let jsonParams = JSON.stringify(params);
        alert(jsonParams)

        $.ajax({
            type:"post",
            url:url,
            data:jsonParams,
            contentType:"application/json" ,// 告诉服务器，当前请求发送过去的数据是json格式字符串
            success:function (data){
                alert(data)
            },
            dataType:"text",

            //允许异步访问时携带cookie
            xhrFields:{
                withCredentials:true
            }
        })
    });
</script>
</html>